import os
import sys


def get_folder_size(dir_name: str) -> int:
    if not dir_name:
        raise Exception(f'输入为空')
    if not os.path.exists(dir_name):
        raise Exception(f'目录{dir_name}不存在')
    if os.path.isfile(dir_name):
        return os.path.getsize(dir_name)
    size = 0
    for root, dirs, files in os.walk(dir_name):
        size += sum([os.path.getsize(os.path.join(root, file)) for file in files])
    return size
    pass


if __name__ == '__main__':
    print(get_folder_size(sys.argv[1]))
